<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="${pageContext.request.contextPath}/css/amazeui.min.css" />
		 <link rel="stylesheet" href="${pageContext.request.contextPath}/css/admin.css" />
        <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.11.3.min.js"></script>
        <script type="text/javascript" src="${pageContext.request.contextPath}/myplugs/js/plugs.js"></script>
        <script src="${pageContext.request.contextPath}/js/layui.js"></script>
        <script>
            function insertFood(title, id) {
                $.jq_Panel({
                    title: title,
                    iframeWidth: 500,
                    iframeHeight: 400,
                    url: "/food/insertFood"
                });
            }
            function updateFood(title,id) {
                console.log("food_id:"+id)
                $.jq_Panel({
                    title: title,
                    iframeWidth: 500,
                    iframeHeight: 420,
                    url: "/food/updateFood?id="+id
                });
            }
            function deletefood(id){
                var datas={};
                datas.id=id;
                var r= confirm("确认删除？");
                if (r==true) {
                    $.ajax({
                        async: false,
                        type: "POST",
                        url: "/food/deleteFood",//注意路径
                        data: datas,
                        dataType: "json",
                        success: function (data) {
                            if (data.result == 'SUCCESS') {
                                alert("删除成功！");
                                window.location.reload();
                            } else {
                                alert("删除失败，失败原因【" + data.result + "】");
                            }
                        },
                        error: function (data) {
                            alert(data.result);
                        }
                    });
                    return true;
                }
                else {
                    return false;
                }


            }
        </script>
	</head>
	<body>
		<div class="admin-content-body">
      <div class="am-cf am-padding am-padding-bottom-0">
        <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">美食浏览</strong><small></small></div>
      </div>

      <hr>

          <div class="am-g">
              <div class="am-u-sm-12 am-u-md-6">
                  <div class="am-btn-toolbar">
                      <div class="am-btn-group am-btn-group-xs">
                          <button type="button" class="am-btn am-btn-default"  onclick="insertFood('新增美食',1)"><span class="am-icon-plus"></span> 新增</button>
                      </div>
                  </div>
              </div>
              <div class="am-u-sm-12 am-u-md-3">

              </div>
              <%--				<div class="am-u-sm-12 am-u-md-3">--%>
              <%--					<div class="am-input-group am-input-group-sm">--%>
              <%--						<input type="text" class="am-form-field" placeholder="请输入用户名">--%>
              <%--						<span class="am-input-group-btn">--%>
              <%--            <button class="am-btn am-btn-default" type="button">搜索</button>--%>
              <%--          </span>--%>
              <%--					</div>--%>
              <%--				</div>--%>
          </div>
<%--        <div class="am-u-sm-12 am-u-md-3">--%>
<%--          <div class="am-input-group am-input-group-sm">--%>
<%--            <input type="text" class="am-form-field" placeholder="请输入留言信息">--%>
<%--          <span class="am-input-group-btn">--%>
<%--            <button class="am-btn am-btn-default" type="button">搜索</button>--%>
<%--          </span>--%>
<%--          </div>--%>
<%--        </div>--%>
      </div>
      <div class="am-g">
        <div class="am-u-sm-12">
          <form class="am-form">
            <table class="am-table am-table-striped am-table-hover table-main">
              <thead>
              <tr>
                  <th class="table-id" style="width: 49.45px">ID</th>
                  <th class="table-title" style="width: 240px">店名</th>
                  <th class="table-type" style="width:136px">类型</th>
                  <th class="table-author am-hide-sm-only" style="width: 57px">地区</th>
                  <th class="table-date am-hide-sm-only" style="width:206px">详细地址</th>
                  <th class="table-author" style="width: 44px">评分</th>
                  <th class="table-author" style="width: 73px">评价人数</th>
                  <th class="table-author" style="width: 73px">人均消费</th>
                  <th class="table-author" style="width: 44px">口味</th>
                  <th class="table-author" style="width: 44px">环境</th>
                  <th class="table-author" style="width: 44px">服务</th>
                  <th class="table-author" style="width: 110px">操作</th>
              </tr>
              </thead>
              <tbody>
              <c:forEach items="${foodInfoPageInfo.list}" var="f">
                  <tr>
                      <td>${f.id}</td>
                      <td>${f.name}</td>
                      <td>${f.type}</td>
                      <td class="am-hide-sm-only">${f.area}</td>
                      <td class="am-hide-sm-only">${f.address}</td>
                      <td>${f.point}</td>
                      <td>${f.pointNum}</td>
                      <td>${f.average}</td>
                      <td>${f.kouwei}</td>
                      <td>${f.huanjing}</td>
                      <td>${f.fuwu}</td>
                      <td>
                          <div class="am-btn-toolbar">
                              <div class="am-btn-group am-btn-group-xs">
                                  <button type="button" class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="updateFood( '修改美食','${f.id}')"><span class="am-icon-pencil-square-o"></span> 编辑</button>
                                  <button type="button" class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only" onclick="return deletefood(${f.id})"><span class="am-icon-trash-o" ></span> 删除</button>
                              </div>
                          </div>
                      </td>
                  </tr>
              </c:forEach>
              </tbody>
            </table>
              <div class="am-cf">
                  共 ${foodInfoPageInfo.total} 条记录
                  <div class="am-fr">
                      <ul class="am-pagination">
                          <li>
                              <a href="/food/foodInfo?pageNum=1">首页</a>
                          </li>
                          <li class="am-active">
                              <a href="/food/foodInfo?pageNum=${foodInfoPageInfo.prePage}">«</a>
                          </li>
                          <li class="am-active">
                              <a href="/food/foodInfo?pageNum=${foodInfoPageInfo.pageNum}">${foodInfoPageInfo.pageNum}</a>
                          </li>
                          <li>
                              <a href="/food/foodInfo?pageNum=${foodInfoPageInfo.nextPage}">»</a>
                          </li>
                          <li>
                              <a href="/food/foodInfo?pageNum=${foodInfoPageInfo.pages}">${foodInfoPageInfo.pages}</a>
                          </li>
                      </ul>
                  </div>
              </div>
            <hr>
          </form>
        </div>

      </div>
    </div>
	</body>
</html>
